<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>promise</title>
  <script>
    let p1 = new Promise((resolve,reject) => {
      // resolve是回调函数，调用该回调承诺对象实例状态变为成功 padding -> fulfilled
      // reject是回调函数，调用该函数承诺对象实例状态变为失败  padding -> rejected
      if(1<0) {
        resolve('请求成功');
      } else {
        reject('请求失败');
      }
    })
    // .then() 内部的回调对应的就是 => resolve()
    // .catch()内部的回调对应的就是 => reject()
    p1.then((res) => {
      console.log(res);
    }).catch((res) => {
      console.log(res);
    })
  </script>
</head>
<body>
  
</body>
</html>